package com.alibaba.aone.casestudy.dao.impl;

import java.util.List;

import com.alibaba.aone.casestudy.common.entity.CaseStudyConditions;
import com.alibaba.aone.casestudy.common.entity.Casestudy;
import com.alibaba.aone.casestudy.common.entity.CasestudyAnalysisParticipant;
import com.alibaba.aone.casestudy.dao.CasestudyDao;
import com.alibaba.intl.commons.framework.ibatis.BaseSqlMapClientDaoSupport;

public class CasestudyDaoImpl extends BaseSqlMapClientDaoSupport implements
		CasestudyDao {

	public void insertCasestudy(Casestudy casestudy) {

	}

	public Casestudy loadCasestudy(String casestudyNo) {
		return (Casestudy) this.getSqlMapClientTemplate().queryForObject(
				"Casestudy.selectCasestudy", casestudyNo);
	}

	public List<Casestudy> listCasestudys(CaseStudyConditions conditions) {
		return (List<Casestudy>) this.getSqlMapClientTemplate()
				.queryForPagination("Casestudy.countCasestudy",
						"Casestudy.selectAll", conditions);
	}

	public int updateCasestudy(Casestudy casestudy) {
		return 0;
	}

	public List<Casestudy> search(CaseStudyConditions caseStudyConditions) {

		return getSqlMapClientTemplate().queryForPagination(
				"Casestudy.countCasestudy", "Casestudy.searchCasestudy",
				caseStudyConditions);
	}

	public void updateAnalysisPartis(List<CasestudyAnalysisParticipant> partis, String csno) {
		List<CasestudyAnalysisParticipant> oldPartis = findAnalysisPartisByCasestudyno(csno);
		
		//this.getSqlMapClientTemplate().in
	}
	
	public List<CasestudyAnalysisParticipant> findAnalysisPartisByCasestudyno(String csno){
		return getSqlMapClientTemplate().queryForList("CasestudyAnalysis.selectPartisByCasestudyno", csno);
	}
	
	public void insertAnalysisParti(CasestudyAnalysisParticipant parti){
		getSqlMapClientTemplate().insert("CasestudyAnalysis.insertParti", parti);
	}
	
	public int deleteAnalysisParti(CasestudyAnalysisParticipant parti){
		return getSqlMapClientTemplate().delete("CasestudyAnalysis.deleteById", parti);
	}

}